package edu.upc.clase.demo.controller;

//import edu.upc.clase.demo.entity.Credential;
import edu.upc.clase.demo.entity.CanchaHorario;
import edu.upc.clase.demo.entity.CanchaHorarioForm;
import edu.upc.clase.demo.entity.Dia;
import edu.upc.clase.demo.entity.Hora;
import edu.upc.clase.demo.service.CanchaHorarioService;
import edu.upc.clase.demo.service.DiaService;
import edu.upc.clase.demo.service.HoraService;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author gian
 */
@Controller("canchaHorarioController")
public class CanchaHorarioController {

    @Autowired
    private CanchaHorarioService canchaHorarioService;
    @Autowired
    private DiaService diaService;
    @Autowired
    private HoraService horaService;
    //@Autowired
    private static List<CanchaHorario> canchasHorarios = new ArrayList<CanchaHorario>();

//    static {
//       //TarifaDia-TarifaNoche-Turno-CodigoDia-CodigoHora-Activo-CodigoCancha
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,1,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,2,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,3,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,4,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,5,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,6,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,7,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,8,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,9,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,10,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,11,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,12,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,13,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,14,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,15,1,1));
//            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,15,1,1));
//        
//        
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,1,0,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,2,0,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,12,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,1,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,1,0,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,2,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,12,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,2,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,1,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,2,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,12,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,3,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,1,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,4,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,1,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,5,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,1,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,6,15,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,1,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,3,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,4,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,5,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,6,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,7,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,8,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,9,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,10,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,11,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,13,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,14,1,1));
////            canchasHorarios.add(new CanchaHorario(30.00,40.00,1,7,15,1,1));
//        
//    }
    private void LlenarLista(int codCancha) {
        canchasHorarios.clear();
        //TarifaDia-TarifaNoche-Turno-CodigoDia-CodigoHora-Activo-CodigoCancha
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 1, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 2, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 3, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 4, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 5, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 6, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 7, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 8, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 9, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 10, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 11, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 12, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 13, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 14, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 1, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 2, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 3, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 4, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 5, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 6, 15, 1, codCancha));
        canchasHorarios.add(new CanchaHorario(30.00, 40.00, 1, 7, 15, 1, codCancha));


    }
    private static Logger log = LoggerFactory.getLogger(CanchaHorarioController.class);

//    @RequestMapping("/canchasHorario/index")
//    public ModelAndView index() {
//        ModelAndView mav = new ModelAndView("canchasHorario/index");
//        LlenarLista();
//        
//        CanchaHorarioForm canchaHorarioForm = new CanchaHorarioForm();
//        canchaHorarioForm.setCanchasHorarios(canchasHorarios);
//        
//        List<Dia> dias = diaService.buscarTodos();
//        mav.addObject("dias", dias);
//        
//        List<Hora> horas = horaService.buscarTodos();
//        mav.addObject("horas", horas);
//        
//        mav.addObject("canchaHorarioForm",canchaHorarioForm);
//        return mav;
//    }
    @RequestMapping(value = "/canchasHorario/index", method = RequestMethod.GET)
    public ModelAndView index(@RequestParam("id") Integer id) {
        ModelAndView mav = new ModelAndView("canchasHorario/index");

        //Listado de Horarios de Canchas
        List<CanchaHorario> canchasHorariosBD = canchaHorarioService.buscar(id);
        mav.addObject("canchasHorarios", canchasHorarios);

        CanchaHorarioForm canchaHorarioForm = new CanchaHorarioForm();


        if (canchasHorariosBD.size() > 0) {

            canchaHorarioForm.setCanchasHorarios(canchasHorariosBD);
        } else {
            LlenarLista(id);

            //CanchaHorarioForm canchaHorarioForm = new CanchaHorarioForm();
            canchaHorarioForm.setCanchasHorarios(canchasHorarios);
        }

//        LlenarLista(id);
//        
//        CanchaHorarioForm canchaHorarioForm = new CanchaHorarioForm();
//        canchaHorarioForm.setCanchasHorarios(canchasHorarios);

        List<Dia> dias = diaService.buscarTodos();
        mav.addObject("dias", dias);

        List<Hora> horas = horaService.buscarTodos();
        mav.addObject("horas", horas);

        mav.addObject("canchasHorariosBD", canchasHorariosBD);

        mav.addObject("canchaHorarioForm", canchaHorarioForm);
        return mav;
    }

    @RequestMapping(value = "/canchasHorario/index", method = RequestMethod.POST)
    // public ModelAndView newHorario(@ModelAttribute("canchaHorarioForm") CanchaHorarioForm canchaHorarioForm) {
    public String newHorario(@ModelAttribute("canchaHorarioForm") CanchaHorarioForm canchaHorarioForm) {
        // System.out.println(contactForm);
        // System.out.println(contactForm.getContacts());
        List<CanchaHorario> canchasHorariosF = canchaHorarioForm.getCanchasHorarios();
        if (null != canchasHorariosF && canchasHorariosF.size() > 0) {
            //  ContactController.contacts = contacts;
            int fila = 0;
            for (CanchaHorario canchaHorario : canchasHorariosF) {
                //System.out.printf("%s \t %s \n", contact.getFirstname(), contact.getLastname());
                //canchaHorario = canchasHorarios.get(fila);
                if (canchaHorario.getActivo() == null) {
                    canchaHorario = canchasHorarios.get(fila);
                    canchaHorario.setActivo(0);
                }else{
                    canchaHorario = canchasHorarios.get(fila);
                }
                canchaHorarioService.insertar(canchaHorario);
                fila++;
            }
        }

        //Listado de Horarios de Canchas
        // List<CanchaHorario> canchasHorarios = canchaHorarioService.buscarTodos();
        //mav.addObject("canchasHorarios", canchasHorarios);



        // return new ModelAndView("show_contact", "contactForm", contactForm);
        return "redirect:/pages/canchas/index";
    }
//    @RequestMapping(value = "/usuarios/new", method = RequestMethod.GET)
//    public ModelAndView newUsuario() {
//        ModelAndView mav = new ModelAndView("usuarios/new");
//        Usuario usuario = new Usuario();
//        mav.getModelMap().put("usuario", usuario);
//        return mav;
//    }
//
//    @RequestMapping(value = "/usuarios/new", method = RequestMethod.POST)
//    public String createUsuario(@ModelAttribute("usuario")Usuario usuario, SessionStatus status) {    
//        usuarioService.insertar(usuario);
//        status.setComplete();
//
//        return "redirect:/pages/usuarios/index";
//        
//    }
//    
//    @RequestMapping(value = "/usuarios/edit", method = RequestMethod.GET)
//    public ModelAndView editUsuario(@RequestParam("id")Integer id) {    
//        ModelAndView mav = new ModelAndView("usuarios/edit");
//        Usuario usuario = usuarioService.buscar(id);
//        mav.getModelMap().put("usuario", usuario);
//        return mav;        
//    }
//    
//    @RequestMapping(value="/usuarios/edit", method=RequestMethod.POST)
//    public String update(@ModelAttribute("usuario") Usuario usuario, SessionStatus status) {
//        usuarioService.actualizar(usuario);
//        status.setComplete();
//        return "redirect:/pages/usuarios/index";
//    }
//    
//    @RequestMapping("/usuarios/delete")
//    public ModelAndView delete(@RequestParam("id")Integer id)
//    {
//        ModelAndView mav = new ModelAndView("redirect:/pages/usuarios/index");
//        Usuario usuario = usuarioService.buscar(id);
//        usuarioService.eliminar(usuario);
//        return mav;
//    }
//    
//    @RequestMapping("/usuarios/login")
//    public ModelAndView login() {
//        ModelAndView mav = new ModelAndView("usuarios/login");
//        Credential credential = new Credential();
//        mav.getModelMap().put("credential", credential);
//        return mav;
//    }    
//    
//    @RequestMapping(value = "/usuarios/autenticar", method=RequestMethod.POST)
//    public String autenticar(@ModelAttribute("credential") Credential credential,HttpServletRequest request) {
//        if (usuarioService.autenticar(credential.getCorreo(), credential.getPassword())) {
//            request.getSession().setAttribute("credential",credential);
//            return "redirect:/pages/usuarios/index";
//        }
//        return "redirect:/pages/usuarios/login";
//    }
//    
//    @RequestMapping("/usuarios/logout")
//    public String logout(HttpServletRequest request) {
//        request.getSession().invalidate();
//        return "redirect:/pages/usuarios/login";
//    }        
}
